﻿using AuthorityCenter.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AuthorityCenter
{
    /// <summary>
    /// 
    /// </summary>
    public partial class main : System.Web.UI.Page
    {
        //private Authority authority = new Authority();
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            HCode.Text = AuthorityModel.GetHardwareCode();
            AuthorityShow.Text = AuthorityModel.GetShowRightInfo();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void AuthorityImport_Click(object sender, EventArgs e)
        {
            //if (MyFileUpload.HasFile)
            //{
            //    string filePath = Server.MapPath("~/UploadFiles/");
            //    if (Directory.Exists(filePath) == false)
            //    {
            //        Directory.CreateDirectory(filePath);
            //    }
            //    string fileName = MyFileUpload.PostedFile.FileName;
            //    int _index = fileName.LastIndexOf("\\");
            //    fileName = fileName.Substring(_index + 1);
            //    filePath = filePath + fileName;
            //    MyFileUpload.SaveAs(filePath);
            //    if(AuthorityModel.ImportFile(filePath))
            //    {
            //        Response.Write("<script>alert('导入成功！')</script>");
            //        HCode.Text = AuthorityModel.GetHardwareCode();
            //        AuthorityShow.Text = AuthorityModel.GetShowRightInfo();
            //    }
            //    else
            //    {
            //        Response.Write("<script>alert('导入失败，请查看授权文件中的硬件码是否跟授权服务器硬件码一致！')</script>");
            //    }
            //    File.Delete(filePath);                
            //}
            //else
            //{
                
            //}
        }
    }
}